package com.zqc.wms.entity;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class APIResponse<T> {

    private Integer code;

    private T data;

    private String message;

    public static <T> APIResponse<T> success(T data) {
        return new APIResponse<>(20000, data, null);
    }

    public static APIResponse success() {
        return success(null);
    }

    public static APIResponse fail(String message) {
        return new APIResponse(50000, null, message);
    }

    public static APIResponse fail(Throwable t) {
        return fail(t.getMessage());
    }
}
